package com.example.demo.exception;

import org.springframework.util.StringUtils;

/**
 * 异常类
 * @author zjj
 * @date 2021-04-27
 */
public class EntityExistException extends RuntimeException{
    public EntityExistException(Class clazz,String filed,String val,String str1,String str2){
        super(EntityExistException.generateMassage(clazz.getSimpleName(),filed,val,str1,str2));
    }
    private static String generateMassage(String entity,String filed,String val,String str1,String str2){
        return StringUtils.capitalize(entity)+" "+str1+" "+filed+" "+val+" "+str2;
    }
    public EntityExistException(Class clazz,String filed,String val){
        super(EntityExistException.generateMassage(clazz.getSimpleName(),filed,val));
    }
    private static String generateMassage(String entity,String filed,String val){
        return StringUtils.capitalize(entity)+" with "+filed+" "+val+" existed";
    }
    
}
